package com.ve.downloader.queue;

import java.util.Arrays;


public class OrderFixQueue implements FixQueue {

    private byte data[];

    @Override
    public boolean equalsArray(byte[] other) {
        return Arrays.equals(data, other);
    }

    public OrderFixQueue(int length) {
        data = new byte[length];
    }

    @Override
    public void push(byte b) {
        for (int i = 0; i < data.length - 1; i++) {
            data[i] = data[i + 1];
        }
        data[data.length - 1] = b;
    }

    @Override
    public byte[] getData() {
        return data;
    }

    @Override
    public String toString() {
        return Arrays.toString(data);
    }

    @Override
    public void clear() {
        Arrays.fill(data, (byte) 0);
    }
}